﻿using System;

namespace MessagePack.Formatters
{
	// Token: 0x02000035 RID: 53
	public class NullableInt64Formatter : IMessagePackFormatter<long?>
	{
		// Token: 0x060000C3 RID: 195 RVA: 0x000040FC File Offset: 0x000024FC
		private NullableInt64Formatter()
		{
		}

		// Token: 0x060000C4 RID: 196 RVA: 0x00004104 File Offset: 0x00002504
		public int Serialize(ref byte[] bytes, int offset, long? value, IFormatterResolver formatterResolver)
		{
			if (value == null)
			{
				return MessagePackBinary.WriteNil(ref bytes, offset);
			}
			return MessagePackBinary.WriteInt64(ref bytes, offset, value.Value);
		}

		// Token: 0x060000C5 RID: 197 RVA: 0x0000412C File Offset: 0x0000252C
		public long? Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize)
		{
			if (MessagePackBinary.IsNil(bytes, offset))
			{
				readSize = 1;
				return null;
			}
			return new long?(MessagePackBinary.ReadInt64(bytes, offset, out readSize));
		}

		// Token: 0x04000029 RID: 41
		public static readonly NullableInt64Formatter Instance = new NullableInt64Formatter();
	}
}
